﻿//客户购物车
var app_url=location.origin;
var total_rmb=0;//总人民币
var total_usd=0;//总美金
(function () {
    var cart = {
        init: function () {
            this.bindEvents();

            this.getStock();
            $('.wrapper').navbarscroll();
        },
        bindEvents: function () {
            var self = this;
            //跳转页面
            $("#categories a").on("click",function(){
            	var link_url=$(this).attr("data-href");
//          	if(APP){
//          		var appJson={};
//         			appJson.title=$(this).attr("data-title");
//         			appJson.url=app_url+link_url;	
//         			YiYi_APP.showNewPage(JSON.stringify(appJson));
//          	}else{
            		location.href = link_url;
            	//}
            });
            //随便逛逛
            $("#go_shop").on("click",function(){
            	var link_url=$(this).attr("data-href");
            	if(APP){
            		var appJson={};
            		appJson.title="裸钻库存";
           			appJson.function_menu="goods_search";
           			appJson.goods_type="1";
           			YiYi_APP.showExistingPage(JSON.stringify(appJson));
            	}else{
            		location.href = link_url;
            	}
            });
            //点击表头排序
            $("#product_table th").on("click", function () {
                var sort = $(this).children("i");

                if (sort.length > 0) {
                    var iSort = $(this).children("i");
                    var sortName = iSort.attr("data-sort");
                    var sortDirect = iSort.attr("data-sort-direct");
                    if (!sortDirect) {
                        sortDirect = "asc";
                    }
                    else if (sortDirect == "asc") {
                        sortDirect = "desc";
                    }
                    else if (sortDirect == "desc") {
                        sortDirect = "";
                    }

                    iSort.attr("data-sort-direct", sortDirect);
                    iSort.removeClass("sort_asc").removeClass("sort_desc").removeClass("sort_normal");
                    iSort.addClass("sort_" + sortDirect);

                    $("th i").not(iSort).removeClass("sort_asc").removeClass("sort_desc").removeClass("sort_normal");
                    $("th i").not(iSort).removeAttr("data-sort-direct");

                    $("th i[data-sort='" + sortName + "']").addClass("sort_" + sortDirect).attr("data-sort-direct", sortDirect);
                    self.getStock();
                }
            });

            //复制表头并固定
            chromatable("product_table");
            $(window).resize(function () {
                updateHeader("product_table");
            });
           //点击详情行关闭
            $("#product_table").on("click", ".stock_detail", function () {
                //$(this).hide();
            });
            //点击行展开详情
            $("#product_table").on("click", "tr.data_tr td", function (event) {
                var td_input = $(this).index();
                if (td_input == 0||td_input == 1 || td_input == 2) {
                    //勾选框不展开详情
                } else {
                    $(this).parent("tr").next(".stock_detail").slideToggle(0);
                }
            });
            
            //点击全选
			$("#checkbox_check_all").on("click",function(){
				$(this).toggleClass("selected")
				if($(this).hasClass("selected")){
					$(".check_list_box").children("span").addClass("selected");					
					$("#check-num").text($("tr.data_tr").length);
					if(CurrentUSD==true && USDprice_td==true){					
						$("#check-total-priceUSD").text(total_usd);
					}
					if(CurrentRMB==true && RMBprice_td==true){
						$("#check-total-price").text(total_rmb);
					}
				}else{
					$(".check_list_box").children("span").removeClass("selected");
					self.countCheck(0,0,0,0,0);//取消
				}
			});
			//列表的勾选框
			$("#stock_body").on("click",".check_rel",function(){
				$(this).children().find("span").toggleClass("selected");
				var pre = parseFloat($(this).parent().next(".stock_detail").find(".per_price span").text());//当前点击行的每卡
				var preUSD = parseFloat($(this).parent().next(".stock_detail").find(".per_priceUSD span").text());//当前点击行的每卡
				var totalprice = parseFloat($(this).parent().next(".stock_detail").find(".total_price span").text());//当前点击行的
				var totalpriceUSD = parseFloat($(this).parent().next(".stock_detail").find(".total_priceUSD span").text());//当前点击行的
				
				//判断是否全选
				var length=$("#stock_body .check_list_box span.checkbox").length;
				var checkLength=$("#stock_body .check_list_box span.selected").length;
				if(length==checkLength){
					$("#checkbox_check_all").addClass("selected");
				}else{
					$("#checkbox_check_all").removeClass("selected");
				}				
				if($(this).children().find("span").hasClass("selected")){
					self.countCheck(1,pre,totalprice,preUSD,totalpriceUSD);//选中
				}else{
					self.countCheck(2,pre,totalprice,preUSD,totalpriceUSD);//取消
				}
				
			});
			$("#stock_body").on("click",".check_list_td",function(){
				$(this).prev().children().find("span").toggleClass("selected");
				var pre = parseFloat($(this).prev().parent().next(".stock_detail").find(".per_price span").text());//当前点击行的每卡
				var preUSD = parseFloat($(this).prev().parent().next(".stock_detail").find(".per_priceUSD span").text());//当前点击行的每卡
				var totalprice = parseFloat($(this).parent().next(".stock_detail").find(".total_price span").text());//当前点击行的
				var totalpriceUSD = parseFloat($(this).parent().next(".stock_detail").find(".total_priceUSD span").text());//当前点击行的
                console.log(totalpriceUSD)
				//判断是否全选
				var length=$("#stock_body .check_list_box span.checkbox").length;
				var checkLength=$("#stock_body .check_list_box span.selected").length;
				if(length==checkLength){
					$("#checkbox_check_all").addClass("selected");
				}else{
					$("#checkbox_check_all").removeClass("selected");
				}				
				if($(this).prev().children().find("span").hasClass("selected")){
					self.countCheck(1,pre,totalprice,preUSD,totalpriceUSD);//选中
				}else{
					self.countCheck(2,pre,totalprice,preUSD,totalpriceUSD);//取消
				}
				
			});

            //购物车详情选中颜色勾选
            $("#stock_body").on("click",".check_list_td2",function(){
                $(this).prev().prev().children().find("span").toggleClass("selected");
                var pre = parseFloat($(this).prev().parent().next(".stock_detail").find(".per_price span").text());//当前点击行的每卡
                var preUSD = parseFloat($(this).prev().parent().next(".stock_detail").find(".per_priceUSD span").text());//当前点击行的每卡
                var totalprice = parseFloat($(this).parent().next(".stock_detail").find(".total_price span").text());//当前点击行的
                var totalpriceUSD = parseFloat($(this).parent().next(".stock_detail").find(".total_priceUSD span").text());//当前点击行的
                //判断是否全选
                var length=$("#stock_body .check_list_box span.checkbox").length;
                var checkLength=$("#stock_body .check_list_box span.selected").length;
                if(length==checkLength){
                    $("#checkbox_check_all").addClass("selected");
                }else{
                    $("#checkbox_check_all").removeClass("selected");
                }
                if($(this).prev().prev().children().find("span").hasClass("selected")){
                    self.countCheck(1,pre,totalprice,preUSD,totalpriceUSD);//选中
                }else{
                    self.countCheck(2,pre,totalprice,preUSD,totalpriceUSD);//取消
                }

            });


            //移除购物车
            $(".remove-cart-btn").on("click", function (ev) {
            	var catrId = $("#cart .check_list_box span.selected").attr("lang");
            	if($("#cart .check_list_box span").is(".selected")){
            		myApp.confirm(_('确定移除购物车吗？'),'',function(){
            			self.removeCart(catrId);
            		});
            	}else{
            		myApp.alert(_("请选择"));
            	}
            });
            //购买
			$("#add_to_order").on("click",function(){
				 var cartlistCb = $("#cart .check_list_box span.selected");//tbody中checked的
                if (cartlistCb.length == 0) {
                	myApp.alert(_("请选择"));
                } else {
                	var orderJson={};
                	orderJson.orderID = [];
                	orderJson.type="stocks";
                	orderJson.form="cart";
                	orderJson.ConfirmUSD=[];//usd 数组
                	orderJson.ConfirmPrice=[];//rmb 数组
                	var z=0;//是否循环完
		            for (var i = 0; i < cartlistCb.length; i++) {		            	
		               orderJson.orderID.push(cartlistCb[i].lang);
		               orderJson.ConfirmUSD.push(Number(cartlistCb[i].getAttribute("data-tPriceUSD")));
		               orderJson.ConfirmPrice.push(Number(cartlistCb[i].getAttribute("data-tPrice")));
		               z++;
		            }	
		            if(z==cartlistCb.length){
			            if(APP){
			            	var appJson={};
			            	appJson.title=_("确认下单");
			            	appJson.url=app_url+"/Customer/SubmitDiaOrder?type=1";
			            	appJson.content=JSON.stringify(orderJson);
			            	YiYi_APP.submitOrder(JSON.stringify(appJson))
			            }else{
			            	var action="/Customer/SubmitDiaOrder?type=1";
						  	form = $("<form method='post' id='params_form' action='"+action+"'>"+
						   	"<input type='text' value='"+JSON.stringify(orderJson)+"' name='params'></form>")
							$("#form_box").html(form);
							$("#params_form").submit();
			            }
			        }
                }
            });
            //跳到证书
            $("#stock_body").on("click","a.cert_link_btn",function(){
            	var link_url=$(this).attr("data-href");
            	if(APP){
            		var appJson={};
           			appJson.title=_("证书");
           			appJson.url=app_url+link_url;	
           			YiYi_APP.showNewPage(JSON.stringify(appJson));
            	}else{
            		location.href=link_url;
            	}
            });
        },
        countCheck:function(type,pre,totalPrice,preUSD,totalPriceUSD){			
			var price=Number($("#check-total-price").text());
			var priceUSD=Number($("#check-total-priceUSD").text());
			var pre_price=parseFloat($("#check-m-rmb").text());
			var pre_priceUSD=parseFloat($("#check-m-usd").text());
			var _num = $(".check_list_box span.selected").length;;	
			if(type==1){//加
				price+=totalPrice;
				priceUSD+=totalPriceUSD;
				pre_price+=pre;
				pre_priceUSD+=preUSD;
			}
			if(type==2){//减
				price-=totalPrice;
				priceUSD-=totalPriceUSD;
				pre_price-=pre;
				pre_priceUSD-=preUSD;
			}
			if(type==0){
				_num=0;
				price=0;
				priceUSD=0;
				pre_price=0;
				pre_priceUSD=0;
			}
			$("#check-num").text(_num);
			
			$("#check-m-rmb").text(formatRMBPrice(pre_price));
			$("#check-m-usd").text(formatUSDPrice(pre_priceUSD));
			if(CurrentRMB==true && RMBprice_td==true){
				$("#check-total-price").text(formatRMBPrice(price));
			}
			if(CurrentUSD==true && USDprice_td==true){
				$("#check-total-priceUSD").text(formatUSDPrice(priceUSD));
			}
		},
        //移除购物车
        removeCart: function () {
            var self = this;
            //获取InventoryID值
            var result = {};
            result.CustomerID = CustomerID;//客户ID
            var cartlistCb = $("#stock_body .check_list_box span.selected");//tbody中checked的
            var _inventoryIDs = "";
            for (var i = 0; i < cartlistCb.length; i++) {
                if (i == 0)
                    _inventoryIDs += cartlistCb[i].lang;
                else
                    _inventoryIDs += "," + cartlistCb[i].lang;
            }
            result.InventoryIDs = _inventoryIDs;
            $.ajax({
                url: "/Customer/DeleteAllCart",//提交地址
                type: "POST",//提交方式
                data: JSON.stringify(result),
                contentType: "application/json; charset=utf-8",
                timeout: 30000, //超时时间：30秒
                success: function (result) {
                    var _result = eval('(' + result + ')');//eval()解析单个json对象
                    if (_result.msgcode == false) {
                        toast(_result.msginfo);
                    } else {
                        $("#removeTip").hide();
                        toast(_("删除成功"));
                        self.getStock();
                        self.clearTotal();
                    }
                },
                error: function(XMLHttpRequest, textStatus, errorThrown){
					myApp.alert(_("网络超时，请重试"));
				}
            });
        },
        //获取购物车
        getStock: function () {
            var self = this;
            myApp.showIndicator();//显示加载中
            var result = {};
            result.CustomerID = CustomerID;//客户ID
            result.PageSize = 1;
            result.PageIndex = 1;
            result.type = 1;
            $.ajax({
                url: "/Customer/GetCartInfos",//提交地址
                type: "POST",//提交方式
                data: JSON.stringify(result),
                contentType: "application/json; charset=utf-8",
                timeout: 30000, //超时时间：30秒
                success: function (result) {
                    var $thead= "<th style='width:7%'>"+_("选中 ")+"</th>"+
                        "<th style='width:8%'>"+_("重量")+"</th>"+
                        "<th style='width:10%'>"+_("颜色")+"</th>"+
                        " <th style='width:10%'>"+_("净度")+"</th>";
                    if(discount_td==true&&CurrentRMB==true && RMBprice_td==true){
                        $thead+="<th style='width:10%'>"+_("切工")+"</th>";
                        $thead+="<th style='width:10%'>"+_("抛光")+"</th>";
                        $thead+="<th style='width:10%'>"+_("对称")+"</th>";
                        $thead+="<th style='width:10%'>"+_("荧光")+"</th>";
                    }else if(discount_td==true&&CurrentUSD==true && USDprice_td==true){
                        $thead+="<th style='width:10%'>"+_("切工")+"</th>";
                        $thead+="<th style='width:10%'>"+_("抛光")+"</th>";
                        $thead+="<th style='width:10%'>"+_("对称")+"</th>";
                        $thead+="<th style='width:10%'>"+_("荧光")+"</th>";
                    }else {
                        if(discount_td==true){
                            $thead+="<th style='width:10%'>"+_("切工")+"</th>";
                            $thead+="<th style='width:10%'>"+_("抛光")+"</th>";
                            $thead+="<th style='width:17%'>"+_("对称")+"</th>";
                            $thead+="<th style='width:18%'>"+_("荧光")+"</th>";
                        }else if(CurrentRMB==true && RMBprice_td==true){
                            $thead+="<th style='width:10%'>"+_("切工")+"</th>";
                            $thead+="<th style='width:10%'>"+_("抛光")+"</th>";
                            $thead+="<th style='width:17%'>"+_("对称")+"</th>";
                            $thead+="<th style='width:18%'>"+_("荧光")+"</th>";
                        }else {
                            if(CurrentUSD==true && USDprice_td==true){
                                $thead+="<th style='width:10%'>"+_("切工")+"</th>";
                                $thead+="<th style='width:10%'>"+_("抛光")+"</th>";
                                $thead+="<th style='width:17%'>"+_("对称")+"</th>";
                                $thead+="<th style='width:18%'>"+_("荧光")+"</th>";
                            }else {
                                $thead+="<th style='width:17%'>"+_("切工")+"</th>";
                                $thead+="<th style='width:18%'>"+_("抛光")+"</th>";
                                $thead+="<th style='width:17%'>"+_("对称")+"</th>";
                                $thead+="<th style='width:18%'>"+_("荧光")+"</th>";
                            }
                        }
                    }
	                    if(discount_td==true){
	                    	$thead+="<th style='width:15%'>"+_("退点")+"</th>";
	                   }
	                   if(CurrentRMB==true && RMBprice_td==true){ //仅美金
		               		$thead+="<th style='width:15%'>"+_("总价 ")+"</th>";
		               	}else{ //全局0和人民币1显示人民币
		               		if(CurrentUSD==true && USDprice_td==true){
		               			$thead+="<th style='width:15%'>"+_("总价 ")+"</th>";             			
		               		}
		               	}
	                $("#product_table_fixed thead tr,#product_table thead tr").html($thead);         
                    self.bindingCart(result);//绑定购物车
                    myApp.hideIndicator();//隐藏加载中
                },
                error: function(XMLHttpRequest, textStatus, errorThrown){
					myApp.hideIndicator();//隐藏加载中
					myApp.alert(_("网络超时，请重试"));
				},
            });
        },

        //绑定数据
        bindingCart: function (result) {
            var _result = eval('(' + result + ')');//eval()解析单个json对象
            $("#incart").html(_result.succ);//未被抢购
            $("#notincart").html(_result.fail);//已被抢购
            $("#totalCart").html(_result.fail + _result.succ);//购物车总数=未被抢购+已被抢购
            total_usd=formatUSDPrice(_result.totalusd);//总美金
            total_rmb=formatRMBPrice(_result.totalrmb);//总人民币
            var tableTbody = $("#stock_body");
            //获取库存成功
            if (_result["msgcode"] == true) {

                if (_result["msginfo"].Data.length == 0) {
                    //无结果
//                  var tr = "";//单行
//                  var tds = "<td colspan='50' style='text-align:center;color:red'>" + _result["msginfo"] + "</td>";// 多列合成一列并居中
//                  tr = "<tr>" + tds + "</tr>";//将多列加到一行
//                  tableTbody.html(tr);//加入到id为customer的table的tbody中
                    $(".null-cart-tip").show();//显示空购物车提示
                	$("#cart").hide();//隐藏购物车列表，主要是隐藏列表的边框线
                } else {
					$("#cart").show();
                    _result = _result["msginfo"].Data;//object       
                    
                    stock_json = _result;
					
                    $("#easy_js").html('<script src="/Js/jquery.easyui.min.js"></script>');
                    var trs = "";//多行数据

                    for (var i = 0; i < _result.length; i++) {

                        var tds = "";//多列
                        var tr = "";//单行
                        var tr_div = "";
                        var data=_result[i];
                        tds += "<td class='check_rel'>"+
                        "<div class='check_list_box'>"+
                        "<span class='checkbox' name='checkbox' lang='" + data.ID + "' data-tPriceUSD='"+formatUSDPrice(data.CustomerDolarPerGrain)+
                        "' data-preUSD='"+formatUSDPrice(data.CustomerDolarPerGrain)+"' data-tPrice='"+formatRMBPrice(data.CustomerRMBPerGrain)+"' data-pre='"
                        +formatRMBPrice(data.CustomerRMBPerCarat)+"'></span></div>";
                        tds += "<td class='check_list_td'>" + data.Weight + "</td>";
                        tds += "<td class='check_list_td2'>" + ColorFormat(data.Color) + "</td>";
                        tds += "<td>" + data.Clarity + "</td>";
                        tds += "<td>" + data.Cut + "</td>";
                        tds += "<td>" + data.Polish + "</td>";
                        tds += "<td>" + data.Symmetry + "</td>";
                        tds += "<td>" + data.Fluorescence + "</td>";
                        if(discount_td==true){
                            tds += "<td>" + data.CustomerDiscountReturn + "</td>";
                        }else{
                        }                        
//                      tds += "<td style='font-weight:bold' class='grain_prcie'>" + formatRMBPrice(data.CustomerRMBPerGrain) + "</td>";
                        if(CurrentRMB==true && RMBprice_td==true){ //人民币
		               		tds += "<td style='font-weight:bold' class='grain_prcie'>"+formatRMBPrice(data.CustomerRMBPerGrain) + "</td>";                        	
		               }else{ //全局0和人民币1显示美金
		               		if(CurrentUSD==true && USDprice_td==true){
		               			tds += "<td style='font-weight:bold' class='grain_prcieUSD'>" + formatUSDPrice(data.CustomerDolarPerGrain) + "</td>";								
		               		}
		               }
                        tr += "<tr class='data_tr'>" + tds + "</tr>";//将多列加到一行
                        tr_div = "<tr class='stock_detail'><td  colspan='50'>"+
                        "<div class='detail_left' style='width:50%'>";
                        if(OriginSN_td==true){
                        	tr_div += "<i onclick='showTotalWord(this)'><b class='custrom'>"+_("原货号")+"：</b><span>" + data.OriginSN+ "</span></i>";
                        }
                        if(SN_td==true){
                            tr_div += "<i onclick='showTotalWord(this)'><b class='custrom'>"+_("货号")+"：</b><span>" + data.SN+ "</span></i>";
                        }
                        	tr_div +="<i style='height:27px'><b style='line-height: 27px;float:left'>"+_("形状")+"：</b><div style='float:left'>" + getShape(GetText("stocks",data.IsFancy,data.Shape,"Shape")) + "</div></i>" +
                        	"<i><b>"+_("奶油")+"：</b>" + MilkyFormat(data.Milky) + "</i>" +
                        	"<i><b>"+_("色调")+"：</b>" + HueFormat(data.Hue) + "</i>" +
                        	"<i><b>"+_("心箭")+"：</b>" + HAFormat(data.HA) + "</i>" +
                        	"<i onclick='showTotalWord(this)'><b class='custrom'>"+_("黑点")+"：</b><span>" + BlackDefectFormat(data.BlackDefect) + "</span></i>" +
                        	"<i onclick='showTotalWord(this)'><b class='custrom'>"+_("瑕疵")+"：</b><span>" + OtherDefectFormat(data.OtherDefect) + "</span></i>" ;
                        	if(place_td==true){
                        		tr_div+="<i><b>"+_("所在地")+"：</b>" + GetText("stocks",data.IsFancy,data.Place,"Place") + "</i>" ;
                        	}                        	
                        	tr_div+="<i><b>"+_("状态")+"：</b>" + GetText("stocks",data.IsFancy,data.Status,"Status") + "</i>" +
                        "</div>" +
                        "<div class='detail_right' style='width:50%'>"+
                        	"<i onclick='showTotalWord(this)'><b class='custrom'>"+_("尺寸")+"：</b><span>" + data.Measurement + "</span></i>";
                            if(certNo_td==true){
                                tr_div +="<i onclick='showTotalWord(this)'><b class='custrom'>"+_("证书号")+"：</b><span>" + NullFormat(data.CertNo) + "</span></i>";
                            }
                        	if(cert_td==true && certNo_td==true){
                        		tr_div+="<i><b class='custrom'>"+_("证书")+"：</b>" + CertTypeFormat(data) + "</i>";
                        	}else if(cert_td==true){
                        		tr_div+="<i><b class='custrom'>"+_("证书")+"：</b>" + data.CertType + "</i>";
                        	}
                        	if(rap_td==true){                        		
                        		tr_div+="<i><b>"+_("Rap")+"：</b>" + data.Rapnet + "</i>";
                        	}
                        	if(CurrentUSD==true && USDperPrice_td==true){
                        		tr_div+="<i class='CurrentUSD per_priceUSD'><b class='custrom'>$/Ct：</b><span>"+formatUSDPrice(data.CustomerDolarPerCarat)+"</span></i>";
                        	}
                        	if(CurrentUSD==true && USDprice_td==true){
		                		tr_div+="<i class='CurrentUSD total_priceUSD'><b class='custrom'>$/Pcs：</b><span>" + formatUSDPrice(data.CustomerDolarPerGrain) + "</span></i>";
		                	}
                        	if(CurrentRMB==true && RMBperPrice_td==true){
		                		tr_div+="<i class='CurrentRMB per_price'><b class='custrom'>￥/Ct：</b><span>" + formatRMBPrice(data.CustomerRMBPerCarat) + "</span></i>";
		                	}
                        	if(CurrentRMB==true && RMBprice_td==true){
		                		tr_div+="<i class='CurrentRMB total_price'><b class='custrom'>￥/Pcs：</b><span>" + formatRMBPrice(data.CustomerRMBPerGrain) + "</span></i>";
                        	}
                            if(UpdateTime_td==true){

                        	    tr_div+="<i><b>"+_("上传")+"：</b>" + DateTimeHandler(data.UpdateTime) + "</i>" ;
                            }
                        "</div></td></tr>";
                        trs += tr + tr_div;//将单行加到多行
                    }
                    tableTbody.html(trs);//加入到id为customer的table的tbody中
                    var $total="";
                    if(CurrentRMB==true && RMBprice_td==true){
                    	$total+='<span class="total-price">'+_("总价")+'￥：<b id="check-total-price">0</b></span>';
                    }
                    if(CurrentUSD==true && USDprice_td==true){
			            $total+='<span class="total-price" >'+_("总价")+'$：<b id="check-total-priceUSD">0</b></span>';
			        }
                    $("#cart-choose-detail").html($total);
                }

            } else {
                //获取库存失败
				$(".null-cart-tip").show();//显示空购物车提示
                $("#cart").hide();//隐藏购物车列表，主要是隐藏列表的边框线
            }
            copyHeader("product_table", "tab_head");//复制表头

        },

        //提交订单（单个或多个立即定购）
        SubmitOrder: function () {
            var self = this;
            var requestOrder = {};
            var cartlistCb = $("#stock_body .check_list_box span.selected");//tbody中checked的
            var _inventoryIDs = "";
            for (var i = 0; i < cartlistCb.length; i++) {
                if (i == 0)
                    _inventoryIDs += cartlistCb[i].lang;
                else
                    _inventoryIDs += "," + cartlistCb[i].lang;
            }

            requestOrder.InventoryIDs = _inventoryIDs;
            requestOrder.CustomerID = CustomerID;
            requestOrder.OrderType = "1";//1客户自己下单,2代下单
            requestOrder.Remarks = $("#remarks").val();

            $.ajax({
                url: "/Customer/SubmitOrder",//提交地址
                type: "POST",//提交方式
                data: JSON.stringify(requestOrder),
                contentType: "application/json; charset=utf-8",
                timeout: 30000, //超时时间：30秒
                success: function (result) {
                    $("#order_remark").hide();
                    var _result = eval('(' + result + ')');//eval()解析单个json对象
                    if (_result.msgcode == true) {
                        toast(_("成功提交订单"));
                        setTimeout(function () {
                            location.href = location.href;
                        },1000);
                        self.clearTotal();
                    } else {
                        toast(_("提交订单失败"));
                    }

                },
                error: function(XMLHttpRequest, textStatus, errorThrown){
					myApp.alert("网络超时，请重试");
				},
            });

        },
        //清空统计栏
        clearTotal: function () {
            $("#check-num").html(0);
            $("#check-m-rmb").html(0);
            $("#check-total-price").html(0);
            $("#check-m-usd").html(0);
            $("#check-total-priceUSD").html(0);
        },

    }

    cart.init();
}());

